<?php

	$siteurl = "http://www.google.com";
	if (isset($_REQUEST['siteurl']))
		$siteurl=$_REQUEST['siteurl'];

/*	$ch = curl_init();

	curl_setopt($ch, CURLOPT_URL,$siteurl);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.2a) Gecko/20021021");
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch, CURLOPT_TIMEOUT, 60);
	
	$ret = curl_exec ($ch);
	curl_close ($ch);

	$ret = fopen ( $siteurl, "r" );

*/

$handle = fopen($siteurl, "rb");
$contents = '';

while (!feof($handle))
{
	$contents .= fread($handle, 8192);
}

fclose($handle);

	// Strip out new lines
	$contents=str_replace("\r","",$contents); 
	$contents=str_replace("\n","",$contents); 



//need to insert a "base tag

	$contents = "<base href=\"".$siteurl."\" />".$contents;

	$simple = strip_selected_tags($contents, '<li>,<ol>', false);
//	$simple = strip_selected_tags($simple, '<!DOCTYPE>,<meta>,<object>,<embed>,<form>,<script>,<link>, <iframe>,<style>', true);
//	$simple = strip_selected_tags($contents, '<!doctype>, <object>,<embed>,<form>,<meta>,<style>,<script>,<link>, <iframe>', true);
	$simple = strip_selected_tags($simple, '<object>,<embed>,<form>,<style>,<script>,<link>, <iframe>', true);

	$parts = split("</html", $simple);

	$simple = $parts[0]."<style>body { font-family:arial; } </style></html>";

	echo $simple;

?>


<?php

function strip_selected_tags($str, $tags = "", $stripContent = false)
    {
        preg_match_all("/<([^>]+)>/i",$tags,$allTags,PREG_PATTERN_ORDER);

        foreach ($allTags[1] as $tag)
	{
	        if ($stripContent)
		{
                	$str = preg_replace("/<".$tag."[^>]*>.*<\/".$tag.">/iU","",$str);
		}
		$str = preg_replace("/<\/?".$tag."[^>]*>/iU","",$str);

        }
        return $str;
    }

?> 
